package com.zone.sdk.module.appstore.entity;

import com.zone.sdk.common.http.base.BaseEntity;

import java.util.List;

public class AppListItemEntity extends BaseEntity {
    private static final long serialVersionUID = -7017001101213345632L;
    /**
     * 商品ID(SPU SKU)
     * 同{@link AppListItemEntity#relatedId} 字段二选一
     *
     * @apiNote app/product/page/v1
     */
    private String id;

    private int spuId;

    private String spuName;

    /**
     * 场景ID / APP ID
     * 同{@link AppListItemEntity#id} 字段二选一
     *
     * @apiNote app/product/page/v1
     */
    private String relatedId;
    /**
     * 商品名称
     *
     * @apiNote app/product/page/v1
     */
    private String productName;//name;
    /**
     * 商品介绍
     *
     * @apiNote app/product/page/v1
     */
    private String description;
    /**
     * 详细介绍
     *
     * @apiNote app/product/page/v1
     */
    private String detailDesc;
    /**
     * 上架时间/发布时间
     *
     * @apiNote app/product/page/v1
     */
    private String shelvesTime;
    /**
     * 生效时间
     *
     * @apiNote app/product/page/v1
     */
    private String validityStartTime;
    /**
     * 失效时间
     *
     * @apiNote app/product/page/v1
     */
    private String validityEndTime;
    /**
     * 价格
     *
     * @apiNote app/product/page/v1
     */
    private String productPrice;
    /**
     * 下载量
     *
     * @apiNote app/product/page/v1
     */
    private int downloadCount;
    /**
     * 销售量
     *
     * @apiNote app/product/page/v1
     */
    private String salesCount;
    /**
     * 服务类目ID（多层级类目关联）
     *
     * @apiNote app/product/page/v1
     */
    private String categoryName;

    /**
     * 属性id
     */
    private String categoryId;
    /**
     * 商品属性
     *
     * @apiNote app/product/page/v1
     */
    private List<CategoryAttr> categoryAttr;
    /**
     * 标签
     *
     * @apiNote app/product/page/v1
     */
    private List<LabelItem> labelList;

    /**
     * 上架状态（0已上架1已下架）
     *
     * @apiNote app/product/page/v1
     */
    private int shelvesState;
    /**
     * 推荐状态（0未推荐1已推荐）
     *
     * @apiNote app/product/page/v1
     */
    private int recommendState;
    /**
     * 唯一编码（商品唯一识别码）
     *
     * @apiNote app/product/page/v1
     */
    private String productCode;
    /**
     * 厂商ID
     *
     * @apiNote app/product/page/v1
     */
    private String manufacturer;
    /**
     * 产品状态
     *
     * @apiNote app/product/page/v1
     */
    private String productStatus;
    /**
     * 素材清单
     *
     * @apiNote app/product/page/v1
     */
    private List<ResourceItem> resourceList;
    /**
     * 产品评分/星级
     *
     * @apiNote app/product/page/v1
     */
    private String productScore;
    /**
     * 文件大小
     */
    private String fileSize;
    /**
     * 状态（确认下这个字段的使用逻辑）
     *
     * @apiNote app/product/page/v1
     */
    private String state;
    /**
     * 图标
     *
     * @apiNote app/product/page/v1
     */
    private String icon;
    /**
     * 背景色
     *
     * @apiNote app/product/page/v1
     */
    private String color;
    /**
     * 图标背景色值 （#ffffff，APP端需要显示ICON背景色时，建议采用该字段）
     */
    private String iconColorValue;
    /**
     * 购买状态：已购买、未购买
     * Tips：购买状态流转请参照下方状态流转图
     */
    private String purchaseStatus;
    /**
     * 安装状态：未安装、下载中、已下载、安装中、已安装、卸载中、已卸载
     * Tips：安装状态流转请参照下方状态流转图
     */
    private String installStatus;

    /**
     * 下载/安装进度 百分比 （下载中需要使用该字段展示百分比进度）
     */
    private Integer progress;
    /**
     * APP状态码	APP状态描述
     * 0	可下载
     * 1	已安装
     * 2	最新版
     * 99	未购买
     */
    private String statusDictionaryType;
    /**
     * Sku Id
     */
    private String skuId;
    /**
     * sku Code
     */
    private String skuCode;
//    private String previewsType;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getRelatedId() {
        return relatedId;
    }

    public void setRelatedId(String relatedId) {
        this.relatedId = relatedId;
    }

    public String getProductName() {
        return productName;
    }

    public void setProductName(String productName) {
        this.productName = productName;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getDetailDesc() {
        return detailDesc;
    }

    public void setDetailDesc(String detailDesc) {
        this.detailDesc = detailDesc;
    }

    public String getShelvesTime() {
        return shelvesTime;
    }

    public void setShelvesTime(String shelvesTime) {
        this.shelvesTime = shelvesTime;
    }

    public String getValidityStartTime() {
        return validityStartTime;
    }

    public void setValidityStartTime(String validityStartTime) {
        this.validityStartTime = validityStartTime;
    }

    public String getValidityEndTime() {
        return validityEndTime;
    }

    public void setValidityEndTime(String validityEndTime) {
        this.validityEndTime = validityEndTime;
    }

    public String getProductPrice() {
        return productPrice;
    }

    public void setProductPrice(String productPrice) {
        this.productPrice = productPrice;
    }

    public String getSalesCount() {
        return salesCount;
    }

    public void setSalesCount(String salesCount) {
        this.salesCount = salesCount;
    }

    public String getCategoryName() {
        return categoryName;
    }

    public void setCategoryName(String categoryName) {
        this.categoryName = categoryName;
    }

    public int getSpuId() {
        return spuId;
    }

    public void setSpuId(int spuId) {
        this.spuId = spuId;
    }

    public String getSpuName() {
        return spuName;
    }

    public void setSpuName(String spuName) {
        this.spuName = spuName;
    }

    public int getDownloadCount() {
        return downloadCount;
    }

    public void setDownloadCount(int downloadCount) {
        this.downloadCount = downloadCount;
    }

    public int getShelvesState() {
        return shelvesState;
    }

    public void setShelvesState(int shelvesState) {
        this.shelvesState = shelvesState;
    }

    public int getRecommendState() {
        return recommendState;
    }

    public void setRecommendState(int recommendState) {
        this.recommendState = recommendState;
    }

    public String getStatusDictionaryType() {
        return statusDictionaryType;
    }

    public void setStatusDictionaryType(String statusDictionaryType) {
        this.statusDictionaryType = statusDictionaryType;
    }

    public String getCategoryId() {
        return categoryId;
    }

    public void setCategoryId(String categoryId) {
        this.categoryId = categoryId;
    }

    public List<CategoryAttr> getCategoryAttr() {
        return categoryAttr;
    }

    public void setCategoryAttr(List<CategoryAttr> categoryAttr) {
        this.categoryAttr = categoryAttr;
    }

    public List<LabelItem> getLabelList() {
        return labelList;
    }

    public void setLabelList(List<LabelItem> labelList) {
        this.labelList = labelList;
    }

    public String getProductCode() {
        return productCode;
    }

    public void setProductCode(String productCode) {
        this.productCode = productCode;
    }

    public String getManufacturer() {
        return manufacturer;
    }

    public void setManufacturer(String manufacturer) {
        this.manufacturer = manufacturer;
    }

    public String getProductStatus() {
        return productStatus;
    }

    public void setProductStatus(String productStatus) {
        this.productStatus = productStatus;
    }

    public List<ResourceItem> getResourceList() {
        return resourceList;
    }

    public void setResourceList(List<ResourceItem> resourceList) {
        this.resourceList = resourceList;
    }

    public String getProductScore() {
        return productScore;
    }

    public void setProductScore(String productScore) {
        this.productScore = productScore;
    }

    public String getFileSize() {
        return fileSize;
    }

    public void setFileSize(String fileSize) {
        this.fileSize = fileSize;
    }

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    public String getIcon() {
        return icon;
    }

    public void setIcon(String icon) {
        this.icon = icon;
    }

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }

//    public String getPreviewsType() {
//        return previewsType;
//    }
//
//    public void setPreviewsType(String previewsType) {
//        this.previewsType = previewsType;
//    }

    public ResourceItem getVideoItem() {
        for (ResourceItem item : resourceList) {
            if (item.isVideo()) {
                return item;
            }
        }
        return null;
    }

    public ResourceItem getPicItem() {
        for (ResourceItem item : resourceList) {
            if (item.isPicture()) {
                return item;
            }
        }
        return null;
    }

    public String getLabel(int idx) {
        if (idx < labelList.size()) {
            if (labelList.get(idx) == null) {
                return null;
            }
            return labelList.get(idx).getLableName();
        }
        return null;
    }

    public String getIconColorValue() {
        return iconColorValue;
    }

    public void setIconColorValue(String iconColorValue) {
        this.iconColorValue = iconColorValue;
    }

    public String getPurchaseStatus() {
        return purchaseStatus;
    }

    public void setPurchaseStatus(String purchaseStatus) {
        this.purchaseStatus = purchaseStatus;
    }

    public String getInstallStatus() {
        return installStatus;
    }

    public void setInstallStatus(String installStatus) {
        this.installStatus = installStatus;
    }

    public Integer getProgress() {
        return progress;
    }

    public void setProgress(Integer progress) {
        this.progress = progress;
    }

    public String getSkuId() {
        return skuId;
    }

    public void setSkuId(String skuId) {
        this.skuId = skuId;
    }

    public String getSkuCode() {
        return skuCode;
    }

    public void setSkuCode(String skuCode) {
        this.skuCode = skuCode;
    }

    public AppEntity buildAppEntity() {
        AppEntity entity = new AppEntity();
        entity.setCode(getId());
        entity.setName(getProductName());
        entity.setProductPrice(getProductPrice());
        return entity;
    }

    public AppDetailEntity buildAppDetailEntity() {
        AppDetailEntity entity = new AppDetailEntity();
        entity.setCode(getId());
        entity.setName(getProductName());
        entity.setProductPrice(getProductPrice());
        AppDetailSku sku = entity.getSkuWithCreate();
        sku.setSkuCode(skuCode);
        sku.setSkuId(Integer.valueOf(skuId));
        return entity;
    }
}
